package com.river.boot.biz.model.vo;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

import cn.hutool.json.JSONUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;

/**
 * 菜品视图对象
 *
 * @author JiangCheng Xiang
 * @since 2025-04-24 21:04
 */
@Getter
@Setter
@Schema(description = "菜品视图对象")
public class ProductVO implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    private Long id;
    @Schema(description = "店铺ID")
    private Long shopId;
    @Schema(description = "店铺名称")
    private String shopName;
    @Schema(description = "分类ID")
    private Long categoryId;
    @Schema(description = "分类名称")
    private String categoryName;
    @Schema(description = "菜品名称")
    private String name;
    @Schema(description = "菜品描述")
    private String description;
    @Schema(description = "主图")
    private String mainImage;
    @Schema(description = "多图")
    private List<String> imageList;
    private String imageListJson;
    @Schema(description = "现价")
    private BigDecimal price;
    @Schema(description = "原价")
    private BigDecimal originalPrice;
    @Schema(description = "成本价")
    private BigDecimal costPrice;
    @Schema(description = "库存(-1表示无限)")
    private Integer stock;
    @Schema(description = "销量")
    private Integer sales;
    @Schema(description = "标签数组['招牌','辣']")
    private List<String> tags;
    private String tagsJson;
    @Schema(description = "排序权重")
    private Integer sort;
    @Schema(description = "状态：1-上架 0-下架")
    private Integer status;
    @Schema(description = "创建人 ID")
    private Long createBy;
    @Schema(description = "创建时间")
    private LocalDateTime createTime;
    @Schema(description = "更新人ID")
    private Long updateBy;
    @Schema(description = "更新时间")
    private LocalDateTime updateTime;

    public List<String> tags() {
        if (Objects.isNull(tagsJson)) return null;
        return JSONUtil.toList(tagsJson, String.class);
    }
}
